package com.drivers.news.controller;


import com.drivers.model.OrderInformation.OrderInformation;
import com.drivers.model.R;
import com.drivers.model.chatMessage.ChatMessage;
import com.drivers.model.ordercomplaint.OrderComplaint;
import com.drivers.news.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orderInfo")
@Slf4j
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;

    @RequestMapping("/showOrderStatus")
    @Transactional
    public Integer showOrderStatus(){
        log.info("showOrderStatus:进入接口");
        Integer integer = orderInfoService.showOrderStatus();
        log.info("showOrderStatus:{}",integer);
        if (integer != null){
            return integer;
        }
        return 0;
    }
    @RequestMapping("/showOrderStatusOver")
    @Transactional
    public Integer showOrderStatusOver(){
        log.info("showOrderStatusOver:进入接口");
        Integer integer = orderInfoService.showOrderStatusOver();
        log.info("showOrderStatusOver333333333333333333:{}",integer);
        if (integer != null){
            return integer;
        }
        return 0;
    }
    @RequestMapping("/showAll")
    public R showAll(){
        List<OrderInformation> orderInfos = orderInfoService.showAll();
        return R.ok(orderInfos);
    }
    @RequestMapping("/showAllAppeal")
    public R showAllAppeal(){
        List<OrderInformation> orderInfos = orderInfoService.showAllAppeal();
        return R.ok(orderInfos);
    }
    @RequestMapping("/showAllAppealById/{orderId}")
    public R showAllAppealById(@PathVariable String orderId) {
        return R.ok(orderInfoService.showOrderIdApppeal(orderId));
    }
    @RequestMapping("/addFeedback")
    public R addFeedback(@RequestBody OrderComplaint orderComplaint){
        Integer dataValue = orderInfoService.addFeedback(orderComplaint);
        return R.ok(dataValue);
    }
    @RequestMapping("/findSelectDriver/{id}")
    public R findSelectDrivers(@PathVariable Integer id){
        return R.ok(orderInfoService.findSelectDrivers(id));
    }
    @RequestMapping("/selectMessage")
    public R selectMessages( ChatMessage chatMessage) {
        return R.ok(orderInfoService.selectMessages(chatMessage));
    }
    @RequestMapping("/findPassenger/{id}")
    public R findPassengers(@PathVariable Integer id){
        return R.ok(orderInfoService.findPassengers(id));
    }
    @RequestMapping("/showHeatMap")
    public R showHeatMap(){
        return R.ok(orderInfoService.showHeatMap());

    }
}
